package br.com.agoy.weppy.dnfeed.jornais.diariodonordeste.reader;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

import br.com.agoy.weppy.dnfeed.domain.Jornal;
import br.com.agoy.weppy.dnfeed.reader.ReaderAbstract;

public class DiarioDoNordesteReader extends ReaderAbstract {
	
	/**
	 * URL do Jornal
	 * Exemplo: 
	 * 
	 * Jornal do dia:
	 * http://diariodonordeste.globo.com/capa.asp
	 * 
	 * Jornal anterior: 
	 * http://diariodonordeste.globo.com/anteriores_carregar.asp?codigo=2792
	 */
	private String urlJornal;
	
	/**
	 * 
	 * @param urlJornal
	 */
	public DiarioDoNordesteReader(String urlJornal) {
		this.urlJornal = urlJornal;
	}
	
	
	public List<String> read(Jornal jornal){
		
		return null;
		
	}
	
	/**
	 * 
	 * @param url
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	private String obterHtmlDaMateria(String url) throws ClientProtocolException, IOException{
		String pagina = "";
		
		HttpClient httpclient = new DefaultHttpClient();
		HttpGet httpget = new HttpGet("http://localhost/");
		HttpResponse response = httpclient.execute(httpget);
		HttpEntity entity = response.getEntity();
		if (entity != null) {
		    InputStream instream = entity.getContent();
		    int l;
		    byte[] tmp = new byte[2048];
		    while ((l = instream.read(tmp)) != -1) {
		    }
		}
		
		return pagina;
		
	}
	
	/**
	 * 
	 * @return
	 */
	public String extrairNoticia(){
		
		return "";
	}

}
